<template>
 <!-- 底部部分 -->
  <div>
    <footer class="footer">
      <span class="todo-count">剩余<strong>{{ list.length }}</strong></span>
      <ul class="filters" @click="$emit('changeType',type)">
        <li>
          <a @click.prevent="type='all'" :class="{ selected:type === 'all' }" href="#/">全部</a>
        </li>
        <li>
          <a @click.prevent="type='active'" :class="{ selected:type === 'active' }" href="#/active">进行中</a>
        </li>
        <li>
          <a @click.prevent="type='completed'" :class="{ selected:type === 'comp' }" href="#/completed">已完成</a>
        </li>
      </ul>
      <button v-show="showClear" @click="hClear" class="clear-completed">清除已完成</button>
    </footer>
  </div>
</template>

<script>
export default {
  name: 'VueDemoTodoFooter',

  props:{
    list:{
      type:Array,
      required:true
    }
  },
  data(){
    return {
      type:'all'
    }
  },


  methods: {
    hClear(){
      this.$emit('clearDone')
    }
  },
  computed:{
    // leftCount(){
    //   return this.list.length
    // },
    showClear(){
      return this.list.some(item => item.isDone)
    }
  }
};
</script>

<style scoped>

</style>